using System;
using System.Data;
using System.Collections;

namespace Company.Product.Entity
{
    /// <summary>
    /// Summary description for KeHoachChiTieu.
    /// </summary>
    public class KeHoachChiTieuList : CollectionBase
    {
        public KeHoachChiTieuList()
        {
        }

        public void Add(KeHoachChiTieu entity)
        {
            this.List.Add(entity);
        }

        public void Add(KeHoachChiTieuList list)
        {
            foreach (KeHoachChiTieu entity in list)
            {
                this.Add(entity);
            }
        }

        public new virtual Enumerator GetEnumerator()
        {
            return new Enumerator(this);
        }
        public virtual KeHoachChiTieu this[int index]
        {
            get
            {
                return (KeHoachChiTieu)this.List[index];
            }
            set
            {
                this.List[index] = value;
            }
        }

        public virtual KeHoachChiTieu Find(Int32 IDChiTieu)
        {
            foreach (KeHoachChiTieu obj in this.List)
            {
                if (obj.IDChiTieu == IDChiTieu)
                {
                    return obj;
                }
            }
            return null;
        }

        public Int32 getTongChiTieu()
        {
            Int32 tong = 0;
            foreach (KeHoachChiTieu item in List)
            {
                tong += item.SoTien;
            }
            return tong;
        }

        public Int32 getTongThuNhap()
        {
            Int32 tong = 0;
            foreach (KeHoachChiTieu item in List)
            {
                if (item.SoTien > 0)
                {
                    tong += item.SoTien;
                }
            }
            return tong;
        }

        public Int32 getTongTieuXai()
        {
            Int32 tong = 0;
            foreach (KeHoachChiTieu item in List)
            {
                if (item.SoTien < 0)
                {
                    tong += item.SoTien;
                }
            }
            return tong;
        }

        #region Inner Classes
        /// <summary>
        /// Type-specific enumeration class, used by LogCollection.GetEnumerator.
        /// </summary>
        public class Enumerator : IEnumerator
        {
            private IEnumerator wrapped;

            public Enumerator(KeHoachChiTieuList collection)
            {
                this.wrapped = ((CollectionBase)collection).GetEnumerator();
            }

            public KeHoachChiTieu Current
            {
                get
                {
                    return (KeHoachChiTieu)(this.wrapped.Current);
                }
            }

            object IEnumerator.Current
            {
                get
                {
                    return (KeHoachChiTieu)(this.wrapped.Current);
                }
            }

            public bool MoveNext()
            {
                return this.wrapped.MoveNext();
            }

            public void Reset()
            {
                this.wrapped.Reset();
            }
        }
        #endregion
    }
}